#!/bin/sh
##
##  OSSP js - JavaScript Engine
##  Copyright (c) 1998-2006 Mozilla <http://www.mozilla.org/>
##
##  This file is part of OSSP js, a distribution of the Mozilla JavaScript
##  reference implementation, which can found at http://www.ossp.org/pkg/lib/js/
##
##  Permission to use, copy, modify, and distribute this software for
##  any purpose with or without fee is hereby granted, provided that
##  the above copyright notice and this permission notice appear in all
##  copies.
##
##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
##  SUCH DAMAGE.
##
##  js-config.in: library build utility
##

DIFS=' 
'

prefix="@prefix@"
exec_prefix="@exec_prefix@"

js_prefix="$prefix"
js_exec_prefix="$exec_prefix"
js_datarootdir="@datarootdir@"
js_bindir="@bindir@"
js_libdir="@libdir@"
js_includedir="@includedir@"
js_mandir="@mandir@"
js_datadir="@datadir@"
js_acdir="@datadir@/aclocal"
js_libs="@LIBS@"
js_version="@JS_VERSION@"

help=no
version=no

usage="js-config"
usage="$usage [--help] [--version]"
usage="$usage [--prefix] [--exec-prefix] [--bindir] [--libdir] [--includedir] [--mandir] [--datadir] [--acdir]"
usage="$usage [--cppflags] [--cflags] [--ldflags] [--libs]"
if [ $# -eq 0 ]; then
    echo "js-config:Error: Invalid option" 1>&2
    echo "js-config:Usage: $usage" 1>&2
    exit 1
fi
output=''
all=no
prev=''
OIFS="$IFS" IFS="$DIFS"
for option
do
    if [ ".$prev" != . ]; then
        eval "$prev=\$option"
        prev=''
        continue
    fi
    case "$option" in
        -*=*) optarg=`echo "$option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
           *) optarg='' ;;
    esac
    case "$option" in
        --help|-h)
            echo "Usage: $usage"
            exit 0
            ;;
        --version|-v)
            echo "OSSP js $js_version"
            exit 0
            ;;
        --all)
            all=yes
            ;;
        --prefix)
            output="$output $js_prefix"
            ;;
        --exec-prefix)
            output="$output $js_exec_prefix"
            ;;
        --bindir)
            output="$output $js_bindir"
            ;;
        --libdir)
            output="$output $js_libdir"
            ;;
        --includedir)
            output="$output $js_includedir"
            ;;
        --mandir)
            output="$output $js_mandir"
            ;;
        --datadir)
            output="$output $js_datadir"
            ;;
        --acdir)
            output="$output $js_acdir"
            ;;
        --cppflags)
            output="$output -DOSSP -DXP_UNIX -I$js_includedir/js"
            ;;
        --cflags)
            : # none
            ;;
        --ldflags)
            output="$output -L$js_libdir"
            ;;
        --libs)
            output="$output -ljs $js_libs"
            ;;
        * )
            echo "js-config:Error: Invalid option" 1>&2
            echo "js-config:Usage: $usage" 1>&2
            exit 1;
            ;;
    esac
done
IFS="$OIFS"
if [ ".$prev" != . ]; then
    echo "js-config:Error: missing argument to --`echo $prev | sed 's/_/-/g'`" 1>&2
    exit 1
fi
if [ ".$output" != . ]; then
    echo $output
fi

